type Toptions_ONCHANGE = {
    /** 修改事件回调方法 */
    onchange?: Tevent_callback;
};

/**
 * 可修改控件注解
 * @param target 目标类型
 */
function AConchange(target: any) {
    if (!U.isSubClass(__CVP__, target)) { return; }

    // 处理器
    const original_options_handlers = target.prototype.options_handlers;
    target.prototype.options_handlers = function (this: __CVP__<any>) {
        const options_handlers = original_options_handlers.call(this);

        U.O.setDefaultValue(options_handlers, 'onchange', _CP_.OPTIONS_HANDLER.get('function'));

        return options_handlers;
    };

    // 初始化
    const original_afterInitializer = target.prototype.afterInitializer;
    target.prototype.afterInitializer = function (this: __CVP__<any>) {
        original_afterInitializer.call(this);

        // 监听修改事件
        if (Object.prototype.hasOwnProperty.call(this.options, 'onchange')) {
            const ele = this.ele;
            ele.on('change', (event) => {
                // 禁用的控件不回调
                if (ele.hasClass(_CP_.CLASSES.DISABLED)) {
                    event.preventDefault();// 阻止默认行为
                    return;
                }
                const onchange = ele.ele()!.creator!.options.onchange;
                if (onchange) { onchange.call(ele, event); }
            });
        }
    };
}
